// 导入依赖模块
yepjs.require("YBA.Data.ajax");

yepjs.define("login", {

    NS: "YBA.Data",

    field: {
        /*
         * 用户登录接口
         * @data {
            username    用户名    string    必填
            password    密码    string    必填
        }
         */
        loginSubmit:function (data, success, error) {
            YBA.Data.ajax({
                url: "/login",
                data: data,
                type: "POST",
                success: success,
                error: error
            });
        },
        /*
         * 用户登出接口
         * @data {

        }
         */
        logout:function(data, success, error){
            YBA.Data.ajax({
                url: "/logout",
                data: data,
                type: "POST",
                success: success,
                error: error
            });
        },
        /*
         * 账号第一次登陆验证密码修改
         * @data {
			userId:   用户id   必选
			oldPassword:    旧密码    必选
			newPassword:	新密码   必选
			sendPhone:		移动电话   必选
			code:		验证码   必选
        }
         */
        oncePasswordUpdate:function(data, success, error){
            YBA.Data.ajax({
                url: "/token/short_message/update_password",
                data: data,
                type: "POST",
                success: success,
                error: error
            });
        },
        /*
         * 获取短信验证码
         * @data {
			sendPhone:		移动电话   必选
			tokennawang:    默认值"tokennawang"
        }
         */
        getMessageCode:function(data, success, error){
            YBA.Data.ajax({
                url: "/token/short_message/send",
                data: data,
                type: "GET",
                success: success,
                error: error
            });
        },
        /*
         * 忘记密码获取忘记密码用户
         * @data {
			username:		用户名   必选
        }
         */
        getForgetUser:function(data, success, error){
            YBA.Data.ajax({
                url: "/user/token/username",
                data: data,
                type: "GET",
                success: success,
                error: error
            });
        },
        /*
         * 验证码接口
         * @data {

        }
         */
        getCode:function (dom) {
            dom.attr("src",ctx+"/api/code?timestamp="+ new Date().getTime());
        }
    }
});
